package com.example.administrator.zhongyichou.net.core;

import com.alibaba.fastjson.JSONArray;
import com.example.administrator.zhongyichou.help.UrlReplace;
import com.example.administrator.zhongyichou.net.presentor.JoinActionAPI;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;
import retrofit2.Retrofit;

/**
 * 普通post请求
 */
public class JoinActionHttpLoader extends HttpLoader {


    private Map<String, String> map;
    private Map<String, JSONArray> map1;
    private String url;

    /**
     * 构造传递监听的接口，以及需要被解析的字节码文件
     *
     * @param parseClass
     */
    public JoinActionHttpLoader(Class<? extends GsonBaseProtocol> parseClass) {
        super(parseClass);
    }

    public void setParams(String url, Map<String, String> map, Map<String, JSONArray> map1) {
        setResponseUrl(UrlReplace.replace(url));
        map.put("cmd", url);
        this.map = map;
        this.map1 = map1;
    }


    @Override
    public Observable<ResponseBody> structureObservable(Retrofit mRetrofit) {
        JoinActionAPI requestAPI = mRetrofit.create(JoinActionAPI.class);
        Observable<ResponseBody> info = requestAPI.getRequest(map, map1);
        return info;
    }
}
